home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / ckpt_create.z / ckpt_create
Encoding:
Text File  |  2002-10-03  |  18.7 KB  |  463 lines

  1.  
  2.  
  3.  
  4. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      ckpt_setup, ckpt_create, ckpt_restart, ckpt_stat, ckpt_remove -
  10.      checkpoint and restart (CPR) library interfaces
  11.  
  12. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.      #include <ckpt.h>
  14.  
  15.      int ckpt_setup(struct ckpt_args *_a_r_g_s[], size_t _n_a_r_g_s);
  16.  
  17.      int ckpt_create(const char *_p_a_t_h, ckpt_id_t _i_d, u_long _t_y_p_e,
  18.           struct ckpt_args *_a_r_g_s[], size_t _n_a_r_g_s);
  19.  
  20.      ckpt_id_t ckpt_restart(const char *_p_a_t_h, struct ckpt_args *_a_r_g_s[],
  21.           size_t _n_a_r_g_s);
  22.  
  23.      int ckpt_stat(const char *_p_a_t_h, struct ckpt_stat **_s_p);
  24.  
  25.      int ckpt_remove(const char *_p_a_t_h);
  26.  
  27. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  28.      The functions provided here are used to issue checkpoint and restart
  29.      (CPR) requests to a process or group of processes.  The _c_k_p_t__s_e_t_u_p,
  30.      _c_k_p_t__c_r_e_a_t_e, _c_k_p_t__r_e_s_t_a_r_t, and _c_k_p_t__r_e_m_o_v_e routines are implemented
  31.      according to the IEEE standard POSIX 1003.1m Draft 1, with minor
  32.      modifications (described below).  The _c_k_p_t__s_t_a_t function is an IRIX
  33.      extension.  Silicon Graphics intends to follow the future development of
  34.      POSIX 1003.1m draft standards and endeavor to be compliant.
  35.  
  36.    cccckkkkpppptttt____sssseeeettttuuuupppp
  37.      This routine currently does not perform any operation on IRIX systems.
  38.      The interface is reserved for future addition of features.  The POSIX
  39.      _c_k_p_t__a_r_g_s structure defined in <ckpt.h> includes the following members:
  40.  
  41.           unsigned long   ckpt_type;      /* data type */
  42.           void            *ckpt_data;     /* data */
  43.  
  44.      None of the POSIX _c_k_p_t__t_y_p_e definitions (CKPT_ID, CKPT_LOCK, CKPT_SIGNAL,
  45.      CKPT_POSTRESTART, CKPT_PRERESTART, and CKPT_POSTCREATE) is implemented in
  46.      IRIX because CPR handles these functions directly and transparently.
  47.  
  48.    cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee
  49.      This routine performs a checkpoint operation against a process or group
  50.      of processes.  It creates a set of checkpoint statefiles in the directory
  51.      _p_a_t_h, based on the user-specified checkpoint ID _i_d, which has a _t_y_p_e as
  52.      defined in <ckpt.h>:
  53.  
  54.      P_PID   for Unix process ID
  55.      P_PGID  for Unix process group ID
  56.      P_SID   for Unix process session ID; see _t_e_r_m_i_o(7)
  57.      P_ASH   for IRIX Array Session ID; see _a_r_r_a_y__s_e_r_v_i_c_e_s(5)
  58.      P_HID   for process hierarchy (tree) rooted at that PID
  59.      P_SGP   for IRIX sproc shared group; see _s_p_r_o_c(2)
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  71.  
  72.  
  73.  
  74.      P_JID   for IRIX job ID
  75.  
  76.      Note that _c_k_p_t__i_d__t is defined as an _i_n_t_6_4__t type in <ckpt.h>.  The
  77.      original POSIX standard requires _i_d to be a _p_i_d__t which is not long
  78.      enough to support the SGI 64-bit Array ID (ASH) number or the SGI 64-bit
  79.      Job ID (JID) number.  However, any application binary using regular POSIX
  80.      _c_k_p_t__c_r_e_a_t_e should work fine since type casting from 32-bit _p_i_d__t to 64-
  81.      bit _c_k_p_t__i_d__t is transparent.
  82.  
  83.      The *_a_r_g_s[] and _n_a_r_g_s arguments from the POSIX draft standard, similar to
  84.      the definitions in _c_k_p_t__s_e_t_u_p, are ignored in IRIX.
  85.  
  86.      See _c_p_r(1) for more information about the CPR attribute file $_H_O_M_E/._c_p_r,
  87.      checkpointable objects and limitations, the SIGCKPT and SIGRESTART
  88.      signals, event handling using _a_t_c_h_e_c_k_p_o_i_n_t(3C) and _a_t_r_e_s_t_a_r_t(3C), CPR
  89.      security, and other issues.
  90.  
  91.      In addition to the CPR attribute file, a global variable _c_p_r__f_l_a_g_s
  92.      defined in <ckpt.h> may specify checkpoint-related options.  The options
  93.      available are:
  94.  
  95.      CKPT_OPENFILE_DISTRIBUTE
  96.           This flag alters the default location, which is the centralized
  97.           directory given by _p_a_t_h, for saving open files.  Instead, open files
  98.           are saved in the same directory where the original open files
  99.           resided, with a new and unique name identifying them.  For example,
  100.           if a process has the /_e_t_c/_p_a_s_s_w_d file open when a checkpoint is
  101.           issued, with the CKPT_OPENFILE_DISTRIBUTE bit set, the /_e_t_c/_p_a_s_s_w_d
  102.           file is saved distributively in /_e_t_c/_p_a_s_s_w_d._c_k_p_t._p_i_d_X_X_X.  Distribute
  103.           mode is useful when disk space is a concern.  However, the
  104.           centralized mode (the default) is far more secure and self-
  105.           contained.  Users should be cautious when this bit is set.
  106.  
  107.      CKPT_CHECKPOINT_CONT
  108.           This flag makes checkpoint target processes continue running after
  109.           this checkpoint is finished.  It overrides the default WILL policy,
  110.           and the WILL policy specified in a user's CPR attribute file.
  111.  
  112.      CKPT_CHECKPOINT_KILL
  113.           This flag kills checkpoint target processes after this checkpoint is
  114.           finished.  This is the default WILL policy, but overrides a CONT
  115.           setting in the user's CPR attribute file.
  116.  
  117.      CKPT_CHECKPOINT_UPGRADE
  118.           Use this flag only when issuing a checkpoint immediately before an
  119.           operating system upgrade.  This forces a save of all executable
  120.           files and DSO libraries used by the current processes, so that
  121.           target processes can be restarted in an upgraded environment.  This
  122.           flag must be used again if restarted processes must be recursively
  123.           checkpointed in the new environment.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  137.  
  138.  
  139.  
  140.      CKPT_ATTRFILE_IN_CWD
  141.           Use this flag if you would like to checkpoint using the CPR
  142.           attribute file residing in your current working directory (versus
  143.           $HOME/.cpr).
  144.  
  145.    cccckkkkpppptttt____rrrreeeessssttttaaaarrrrtttt
  146.      This routine restarts a set of processes from the statefile created at
  147.      checkpoint time and identified by _p_a_t_h.  If a restart involves more than
  148.      one process, the restart on all processes has to succeed before any
  149.      process is enabled to run.  If one restart in a group fails, all fail.
  150.  
  151.      In addition to the CPR attribute file, a global variable _c_p_r__f_l_a_g_s
  152.      defined in <ckpt.h> may specify restart-related options.  The options
  153.      available are:
  154.  
  155.      CKPT_RESTART_INTERACTIVE
  156.           This flag makes a process or group of processes interactive (that
  157.           is, subject to UNIX job-control), if the original processes were
  158.           interactive.  The calling process or the calling process' group
  159.           leader becomes the group leader of restarted processes, but the
  160.           original process group ID cannot be restored.  Without this flag,
  161.           the default is to restart target processes as an independent process
  162.           group with the original group ID restored.
  163.  
  164.      CKPT_ATTRFILE_IN_CWD
  165.           Use this flag if you would like to restart using the CPR attribute
  166.           file residing in your current working directory (versus $HOME/.cpr).
  167.  
  168.      CKPT_RESTART_MIGRATE
  169.           This flag migrates process memory so it is restored to the location
  170.           in the system topology where the restart is executing (within a
  171.           specific cpuset, within the global cpuset, etc.).  Without this
  172.           option, the default restart behavior on NUMA systems is to restore
  173.           process memory back to where it was at the time of the checkpoint.
  174.           This option has no effect on non-NUMA systems.  See the _m_i_g_r_a_t_i_o_n(3)
  175.           man page for scenarios which may prevent pages from migrating
  176.           properly.
  177.  
  178.  
  179.    cccckkkkpppptttt____rrrreeeemmmmoooovvvveeee
  180.      This routine deletes a statefile identified by _p_a_t_h.  The _c_k_p_t__r_e_m_o_v_e
  181.      routine removes all statefiles, including all the saved open files,
  182.      mapped files, pipe data, and so forth.
  183.  
  184.      Only the superuser and the checkpoint owner can remove checkpoint files.
  185.  
  186.    cccckkkkpppptttt____ssssttttaaaatttt
  187.      This routine is issued to existing statefiles in _p_a_t_h to get basic
  188.      information about the checkpointed processes saved there.  The
  189.      information is returned through a single-link list of _c_k_p_t__s_t_a_t__t
  190.      structures pointed by *_s_p, defined in <ckpt.h>.  Each structure
  191.      represents one process with the following members:
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  203.  
  204.  
  205.  
  206.             struct ckpt_stat  *cs_next;            /* next process */
  207.              long              cs_revision;         /* CPR revision # */
  208.              pid_t             cs_pid;              /* proc pid */
  209.              pid_t             cs_ppid;             /* proc parent pid */
  210.              pid_t             cs_pgrp;             /* proc group leader */
  211.              pid_t             cs_sid;              /* session id */
  212.              struct stat       cs_stat;             /* see stat(2) */
  213.              char              cs_nfiles;           /* # of open files */
  214.              char              cs_comm[PSCOMSIZ];   /* process name */
  215.              char              cs_psargs[PSARGSZ];  /* and arguments */
  216.              char              cs_cdir[MAXPATHLEN]; /* current directory */
  217.              int               cs_board;            /* board (sys/invent.h) */
  218.              int               cs_cpu;              /* cpu (sys/invent.h) */
  219.              int               cs_abi;              /* abi (sys/kabi.h) */
  220.  
  221.      Applications can traverse through the next pointer _c_s__n_e_x_t to reach all
  222.      processes associated with the statefile.
  223.  
  224.      It is important to note that although applications are not required to
  225.      allocate the memory buffers needed for the _s_p linked list, it is an
  226.      application's responsibility to release these memory buffers after
  227.      examining the data.  Applications should follow the _c_s__n_e_x_t link to free
  228.      all of the _c_k_p_t__s_t_a_t__t buffers.  The following example shows how to use
  229.      this function:
  230.  
  231.              ckpt_stat_t *sp, *sp_next;
  232.  
  233.              if (ckpt_stat(path, &sp)) < 0)
  234.                  return (-1);
  235.              while (sp) {
  236.                  /* examine the data sp */
  237.                  ...
  238.                  sp_next = sp->cs_next;
  239.                  free(sp);
  240.                  sp = sp_next;
  241.              }
  242.  
  243. NNNNOOOOTTTTEEEESSSS
  244.      All the CPR interfaces are found in the _l_i_b_c_p_r._s_o DSO, and are loaded at
  245.      runtime if the ----llllccccpppprrrr option is passed to _c_c(1) or _l_d(1).
  246.  
  247.      The contents of ckpt_stat_t are likely to change between releases.
  248.  
  249.      The ckpt_stat() interface is not supported for 32 bit abis running on 64
  250.      bit kernels.
  251.  
  252. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  253.      _c_p_r(1), _c_v_i_e_w(1), _a_t_c_h_e_c_k_p_o_i_n_t(3C), _a_t_r_e_s_t_a_r_t(3C)
  254.  
  255.      IEEE standard POSIX 1003.1m Draft 1, October 1995.  This draft standard
  256.      is still being discussed and modified.  No assurances can be given as to
  257.      when P1003.1m will be approved or what it will contain.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  269.  
  270.  
  271.  
  272. DDDDIIIIAAAAGGGGNNNNOOOOSSSSTTTTIIIICCCCSSSS
  273.      _c_k_p_t__s_e_t_u_p is a no-op interface and currently always returns 0.
  274.  
  275.      _c_k_p_t__c_r_e_a_t_e returns 0 upon success.  Upon failure it returns -1 and sets
  276.      _e_r_r_n_o to indicate one of the following:
  277.  
  278.      [ECKPT]
  279.           An unrecoverable resource, such as a socket connection, is
  280.           associated with the target process.
  281.  
  282.      [EEXIST]
  283.           The file named by _p_a_t_h already exists.
  284.  
  285.      [ENOMEM]
  286.           Checkpointing requires more memory than allowed by the hardware or
  287.           available swap space.
  288.  
  289.      [ENOSPC]
  290.           Space remaining on the device is insufficient for the checkpoint
  291.           file.
  292.  
  293.      [EACCES]
  294.           Search permission is denied on a component of the path prefix or
  295.           write permission is denied on the parent directory of the checkpoint
  296.           file to be created.
  297.  
  298.      [EPERM]
  299.           The calling process does not have appropriate privileges to
  300.           checkpoint one or more of the target processes.
  301.  
  302.      [EBUSY]
  303.           A resource associated with the target process is in use by the
  304.           system.
  305.  
  306.      [ELOOP]
  307.           Too many symbolic links were encountered during resolution of the
  308.           _p_a_t_h argument; a loop probably exists.
  309.  
  310.      [ENOENT]
  311.           The _p_a_t_h argument names a nonexistent directory or points to an
  312.           empty string.
  313.  
  314.      [ENOTDIR]
  315.           A component of the path prefix is not a directory.
  316.  
  317.      [EROFS]
  318.           The checkpoint file being created would reside on a read-only file
  319.           system.
  320.  
  321.      [EINVAL]
  322.           An invalid argument was passed to the function call.  [ESRCH] The
  323.           process or process group specified by _i_d cannot be found.
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  335.  
  336.  
  337.  
  338.      _c_k_p_t__r_e_s_t_a_r_t returns the ID (_c_k_p_t__i_d__t) of the restarted process, process
  339.      group leader, session leader, tree root of processes in an array, tree
  340.      root of a process hierarchy, _s_p_r_o_c group leader, or job.  Note that the
  341.      64-bit return value _c_k_p_t__i_d__t is different from the 32-bit value POSIX
  342.      specifies; however, the difference doesn't affect API compatibility.  On
  343.      failure, _c_k_p_t__r_e_s_t_a_r_t returns -1 and sets _e_r_r_n_o to indicate one of the
  344.      following:
  345.  
  346.      [ECKPT]
  347.           Restart operation can not be completed or an unrecoverable resource
  348.           is associated with the target process.
  349.  
  350.      [EBUSY]
  351.           The system resource required to restart the processes requested is
  352.           already taken at this moment.  For example, a process ID is
  353.           currently being used by another process and if the action ORIGINAL
  354.           is set for the FORK function in the $_H_O_M_E/._c_p_r attribute file.
  355.  
  356.      [EAGAIN]
  357.           A system-imposed limit on the total number of processes belonging to
  358.           a single user (CHILD_MAX) would be exceeded by restarting the target
  359.           process set.
  360.  
  361.      [ENOMEM]
  362.           Restarting the target process set requires more memory than allowed
  363.           by the hardware or available swap space.
  364.  
  365.      [EACCES]
  366.           Search permission is denied on a component of the path prefix.
  367.  
  368.      [EPERM]
  369.           The real user ID of the calling process does not match the real user
  370.           ID of one or more processes defined by the checkpoint file, or the
  371.           calling process does not have appropriate privileges to restart one
  372.           or more of the target processes.
  373.  
  374.      [ELOOP]
  375.           Too many symbolic links were encountered during resolution of the
  376.           _p_a_t_h argument; a loop probably exists.
  377.  
  378.      [ENOENT]
  379.           The _p_a_t_h argument names a nonexistent directory or points to an
  380.           empty string.
  381.  
  382.      [ENOTDIR]
  383.           A component of the path prefix is not a directory.
  384.  
  385.      [EROFS]
  386.           Restarted files would be created in a read-only file system.
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))                                                  cccckkkkpppptttt____ccccrrrreeeeaaaatttteeee((((3333))))
  401.  
  402.  
  403.  
  404.      [EINVAL]
  405.           An invalid argument was passed to the function call.
  406.  
  407.      _c_k_p_t__r_e_m_o_v_e and _c_k_p_t__s_t_a_t return 0 on success.  On failure, they return
  408.      -1 and set _e_r_r_n_o to indicate one of the following:
  409.  
  410.      [EACCES]
  411.           Search permission is denied on a component of the path prefix, or
  412.           write permission is denied on the parent directory of the checkpoint
  413.           file to be removed.
  414.  
  415.      [EPERM]
  416.           The calling process does not have appropriate privileges to remove
  417.           or stat the target statefiles.
  418.  
  419.      [ELOOP]
  420.           Too many symbolic links were encountered during resolution of the
  421.           _p_a_t_h argument; a loop probably exists.
  422.  
  423.      [ENOENT]
  424.           The _p_a_t_h argument names a nonexistent directory or points to an
  425.           empty string.
  426.  
  427.      [ENOTDIR]
  428.           A component of the path prefix is not a directory.
  429.  
  430.      [EROFS]
  431.           The checkpoint file to be removed resides on a read-only file
  432.           system.
  433.  
  434.      [EINVAL]
  435.           The file to be removed is not a checkpoint file.
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.